//
//  XHRTopicVideoView.m
//  BuDeJie
//
//  Created by haoran on 16/4/15.
//  Copyright © 2016年 xuhaoran. All rights reserved.
//

#import "XHRTopicVideoView.h"
#import "XHRTopicItem.h"
#import "XHRSeeBigPictureViewController.h"

@interface  XHRTopicVideoView()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (weak, nonatomic) IBOutlet UILabel *playcountLabel;

@property (weak, nonatomic) IBOutlet UILabel *videotimeLabel;
@end

@implementation XHRTopicVideoView



-(void)awakeFromNib{
    
    self.autoresizingMask = UIViewAutoresizingNone;
    self.imageView.userInteractionEnabled = YES;
    
    [self.imageView addGestureRecognizer: [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(seeBigPicture)]];
    
}

/**
 *  查看大图
 */
-(void)seeBigPicture{
    XHRSeeBigPictureViewController * vc = [[XHRSeeBigPictureViewController alloc]init];
    vc.topicItem = self.topicItem;
    [self.window.rootViewController presentViewController:vc animated:YES completion:nil];
    
}


-(void)setTopicItem:(XHRTopicItem *)topicItem{
    
    _topicItem = topicItem;
    
    // 设置图片
    [self.imageView xhr_setImageWithOriginalImageURL:topicItem.image1 thumbnailImageURL:topicItem.image0 placeholderImage:nil completed:nil];
    
    // 设置播放次数
    if (topicItem.playcount > 10000) {
        self.playcountLabel.text = [NSString stringWithFormat:@"%.1f万播放",topicItem.playcount /10000.0];
    }else{
        self.playcountLabel.text = [NSString stringWithFormat:@"%zd播放",topicItem.playcount];
    }
    // 设置音频时间
    self.videotimeLabel.text = [NSString stringWithFormat:@"%02zd:%02zd",topicItem.videotime / 60, topicItem.videotime % 60];
    
    
}

@end
